//
//  ViewController.m
//  gitExecise
//
//  Created by songhuipan on 16/6/9.
//  Copyright © 2016年 songhuipan. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UITableView *tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //创建一个Button
    UIButton *hlButton = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 200)];
    hlButton.backgroundColor = [UIColor redColor];
    [hlButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:hlButton];
    
    [self.view addSubview:({
        self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        self.tableView.backgroundColor = [UIColor redColor];
        
        _tableView;
        
    })];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
    view.backgroundColor = [UIColor greenColor];
    [self.view addSubview:view];
    UIView *orignalView = view;
    for (NSInteger i = 0; i<100; i++) {
        UIView *newView = [[UIView alloc]initWithFrame:CGRectInset(orignalView.bounds, 4, 4)];
        newView.backgroundColor = i%2?[UIColor orangeColor]:[UIColor blackColor];
        [orignalView addSubview:newView];
        orignalView = newView;

    }
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 50)];
    label.font = [UIFont systemFontOfSize:30];
    label.text = @"盼盼你怎么这么牛逼呢，我爱死你了，哈哈哈哈哈";
    [self.view addSubview:label];

}
- (void)buttonClick:(UIButton *)sender{

    NSLog(@"按钮被点击了");
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
    [self.view addSubview:button];
    button.backgroundColor = [UIColor yellowColor];
    [button addTarget:self action:@selector(myButtonClick:) forControlEvents:UIControlEventTouchUpInside];


    }
- (void)myButtonClick:(UIButton *)sender {
    NSLog(@"hahahhahaha");
    UILabel *hahaLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, 300, 400)];
    hahaLabel.backgroundColor = [UIColor whiteColor];
    hahaLabel.text = @"哈哈哈哈哈哈哈哈哈哈哈哈";
    hahaLabel.textColor = [UIColor blackColor];
    CGFloat kScreenw =[UIScreen mainScreen].bounds.size.width;
    CGFloat kScreenh =[UIScreen mainScreen].bounds.size.height;
    UISearchBar *searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0,kScreenh-60 , kScreenh, 0)];
    [self.view addSubview:searchBar];
    
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    view.backgroundColor = [UIColor greenColor];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, 100, 100)];
    label.text = @"大黄蜂";
    [view addSubview:label];
    [self.view addSubview:view];
    
    

    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 200)];
    view1.backgroundColor = [UIColor redColor];
    NSLog(@"hahhahahah");

    return 5;

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [UITableViewCell new];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return  50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {

    
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
        NSLog(@"哈哈哈哈哈哈哈哈哈哈哈哈");
    
    
    

    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    view.backgroundColor = [UIColor greenColor];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, 100, 100)];
    label.text = @"大黄蜂";
    [view addSubview:label];
    [self.view addSubview:view];
    


    return 100;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 300, 100)];
    imageView.image = [UIImage imageNamed:@"image"];
    return imageView;
}
@end











